Video encoding apparatus and a video decoding apparatus

ABSTRACT

A video encoding apparatus is a video encoding apparatus for subjecting a video image to motion compensated prediction coding, comprising an acquisition module to acquire available blocks of blocks having motion vectors from encoded blocks adjacent to a to-be-encoded block and number of the available blocks, an acquisition/selection module to select one selection block from the encoded available blocks, a selection information encoder to encode selection information specifying the selection block using a code table corresponding to the number of available blocks, and an image encoder to subject the to-be-encoded block to motion compensated prediction coding using a motion vector of the selection block.

CROSS-REFERENCE TO RELATED APPLICATIONS

This is a Divisional Application of U.S. application Ser. No.14/201,412, filed Mar. 7, 2014, which is a Continuation-In-PartApplication of Continuation application Ser. No. 13/325,856 (now U.S.Pat. No. 9,167,273), filed Dec. 14, 2011, which is a ContinuationApplication of PCT Application No. PCT/JP2009/061130, filed Jun. 18,2009, which was published under PCT Article 21(2) in Japanese. Theentire contents of each of the above are incorporated herein byreference.

BACKGROUND OF THE INVENTION

1. Field of the Invention

The present invention relates to a video encoding apparatus and a videodecoding apparatus which derive a motion vector from an encoded anddecoded image and perform a motion compensated prediction.

2. Description of the Related Art

There is a motion compensated prediction as one of techniques used forencoding a video image.

In the motion compensated prediction, a video encoding apparatusacquires a motion vector using a to-be-encoded image to be newly encodedand a local decoded image already generated and generates a predictionimage by carrying out motion compensation using this motion vector.

As one of methods for acquiring a motion vector in the motioncompensated prediction, there is a direct mode for generating aprediction image using a motion vector of a to-be-encoded block derivedfrom the motion vector of an encoded block (refer to Japanese Patent No.4020789 and U.S. Pat. No. 7,233,621). Because the motion vector is notencoded in the direct mode, the number of encoded bits of the motionvector information can be reduced. The direct mode is employed inH.264/AVC.

BRIEF SUMMARY OF THE INVENTION

In the direct mode, a motion vector is generated by a method forcalculating a motion vector from a median value of the motion vector ofan encoded block adjacent to a to-be-encoded block in generating themotion vector of the to-be-encoded block by prediction. Therefore,degrees of freedom for calculating the motion vector calculation arelow. In addition, when a method for calculating a motion vector byselecting one from a plurality of encoded blocks is used for improvingthe degrees of freedom, the position of the block must be always sent asmotion vector selection information in order to indicate the selectedencoded block. For this reason, the number of encoded bits may beincreased.

It is an object of the present invention to provide a video encodingapparatus and a video decoding apparatus which reduce additionalinformation of motion vector selection information while improving thedegrees of freedom for calculating the motion vector by selecting onefrom encoded blocks.

An aspect of the present invention provides a video encoding apparatusfor subjecting a video image to motion compensated prediction encoding,the apparatus comprising an acquisition module for acquiring availableblocks having motion vectors and the number of the available blocks fromencoded blocks adjacent to a to-be-encoded block, a selection module forselecting a selection block from the available blocks of the encodedblocks, a selection information encoding module for encoding selectioninformation specifying the selection block using a code tablecorresponding to the number of the available blocks, and an imageencoding module for subjecting the to-be-encoded block to motioncompensated prediction encoding using the motion vector of the selectedblock.

Another aspect of the present invention provides a video decodingapparatus for subjecting a video image to motion compensated predictiondecoding, the apparatus comprising a selection information decodingmodule for decoding selection information by switching a code tableaccording to the number of available blocks of decoded blocks havingmotion vectors and neighboring a to-be-decoded block, a selection modulefor selecting a selection block from available blocks according to theselection information, and an image decoding module for subjecting ato-be-decoded image to motion compensated prediction decoding using amotion vector of the selection block by the selection module.

BRIEF DESCRIPTION OF THE SEVERAL VIEWS OF THE DRAWINGS

FIG. 1 is a block diagram of a video encoding apparatus related to anembodiment of the present invention.

FIG. 2 is a flowchart representing a processing procedure of the videoencoding apparatus.

FIG. 3 is a flowchart representing a processing procedure of anacquisition/selection module.

FIG. 4A is a diagram for describing a discrimination method based on ablock size.

FIG. 4B is a diagram for describing a discrimination method based on ablock size.

FIG. 4C is a diagram for describing a discrimination method based on ablock size.

FIG. 5 is a diagram for describing a discrimination method by aunidirectional or a bidirectional.

FIG. 6 is a flowchart representing a processing procedure of a selectioninformation encoder.

FIG. 7 shows an example of an index of selection information.

FIG. 8 shows an example of a code table of selection information.

FIG. 9 is a schematic view of a syntax structure.

FIG. 10 shows a data structure of a macroblock layer.

FIG. 11 shows a block diagram of a video decoding apparatus related tothe embodiment of the present invention.

FIG. 12 shows a flowchart representing a processing procedure of thevideo decoding apparatus.

DETAILED DESCRIPTION OF THE INVENTION

There will now be explained embodiments of the present inventionreferring to drawings.

A video encoding apparatus related to an embodiment is described withreference to FIG. 1 hereinafter. A subtracter 101 calculates adifference between an input video signal 11 and a predictive coded videosignal 15, and output a prediction error signal 12. The output terminalof the subtracter 101 is connected to a variable length encoder 111through an orthogonal transformer 102 and a quantizer 103. Theorthogonal transformer 102 orthogonal-transforms a prediction errorsignal 12 from the subtracter 101, and the quantizer 103 quantizes anorthogonal transformation coefficient and outputs quantizationorthogonal transformation coefficient information 13. The variablelength encoder 111 performs variable length encoding on the quantizationorthogonal transformation coefficient information 13 from the quantizer103.

The output terminal of the quantizer 103 is connected to an adder 106through a dequantizer 104 and an inverse orthogonal transformer 105. Thedequantizer 104 dequantizes the quantized orthogonal transformationcoefficient information 13, and converts it in an orthogonaltransformation coefficient. The inverse orthogonal transformer 105converts the orthogonal transformation coefficient to a prediction errorsignal. The adder 106 adds the prediction error signal of the inverseorthogonal transformer 105 and the predictive coded video signal 15 togenerate a local decoded image signal 14. The output terminal of theadder 106 is connected to a motion compensated prediction module 108through a frame memory 107.

The frame memory 107 accumulates a local decoded image signal 14. Asetting module 114 sets a motion compensated prediction mode (aprediction mode) of a to-be-encoded block. The prediction mode includesa unidirectional prediction using a single reference picture and abidirectional prediction using two reference pictures. Theunidirectional prediction includes L0 prediction and L1 prediction ofAVC. A motion compensated prediction module 108 comprises a predictionmodule 109 and an acquisition/selection module 110.

The acquisition/selection module 110 acquires available blocks havingmotion vectors and the number of the available blocks from encodedblocks adjacent to the to-be-encoded block, and selects a selectionblock from the available blocks. The motion compensated predictionmodule 108 performs a prediction using a local decoded image signal 14stored in the frame memory 107 as a reference image and generates apredictive coded video signal 15. The acquisition/selection module 110selects one block (a selection block) from the adjacent blocks adjacentto the to-be-encoded block. For example, the block having an appropriatemotion vector among the adjacent blocks is selected as the selectionblock. The acquisition/selection module 110 selects the motion vector ofthe selection block as a motion vector 16 to be used for the motioncompensated prediction, and sends it to the prediction module 109. Inaddition, the acquisition/selection module 110 generates selectioninformation 17 of the selection block and sends it to the variablelength encoder 111.

The variable length encoder 111 has a selection information encoder 112.The selection information encoder 112 subjects the selection information17 to variable length encoding while switching a code table so as tohave therein the same number of entries as the available blocks ofencoded blocks. The available block is a block having a motion vectoramong encoded blocks adjacent to the to-be-encoded block. A multiplexer113 multiplexes quantized orthogonal transformation coefficientinformation and selection information and output encoded data.

The action of the video encoding apparatus of the above configurationwill be described referring to the flowchart of FIG. 2.

At first a prediction error signal 12 is generated (S11). In generationof this prediction error signal 12, a motion vector is selected, and aprediction image is generated using the selected motion vector. Thesubtracter 101 calculates a difference between the signal of theprediction image, that is, the prediction image signal 15 and the inputvideo signal 11 to generate the prediction error signal 12.

The orthogonal transformer 102 orthogonal-transforms the predictionerror signal 12 to generate an orthogonal transformed coefficient (S12).The quantizer 103 quantizes the orthogonal transformed coefficient(S13). The dequantizer 104 dequantizes the quantized orthogonaltransformed coefficient information (S14), and then subjects it toinverse orthogonal transform to provide a reproduced prediction errorsignal (S15). The adder 106 adds the reproduced prediction error signaland the predictive coded video signal 15 to generate a local decodedimage signal 14 (S16). The local decoded image signal 14 is stored inthe frame memory 107 (as a reference picture) (S17), and the localdecoded image signal read from the frame memory 107 is inputted to themotion compensated prediction module 108.

The prediction module 109 of the motion compensated prediction module108 subjects the local decoded image signal (reference image) to motioncompensated prediction using the motion vector 16 to generate thepredictive coded video signal 15. The predictive coded video signal 15is sent to the subtracter 101 to calculate a difference with respect tothe input video signal 11, and further is sent to the adder 106 togenerate the local decoded image signal 14.

The acquisition/selection module 110 selects a selection block fromadjacent blocks, generates selection information 17, and sends a motionvector 16 of the selection block to the prediction module 109 whichperforms the motion compensated prediction using the motion vector ofthe selection block. The selection information 17 is sent to theselection information encoder 112. When the selection block is selectedfrom the adjacent blocks, the adjacent block having the appropriatemotion vector allowing the amount of encoded bits to be decreased isselected.

The orthogonal transformation coefficient information 13 quantized withthe quantizer 103 also is input to the variable length encoder 111 andis subjected to variable length coding (S18) The acquisition/selectionmodule 110 outputs the selection information 16 used for motioncompensated prediction, and inputs it to the selection informationencoder 112. The selection information encoder 112 switches the codetable so as to have therein the same number of entries as the availablebocks of the encoded blocks neighboring the to-be-encoded block andhaving motion vectors, and the selection information 17 is subjected tovariable length coding. The multiplexer 113 multiplexes the quantizedorthogonal transformation coefficient information from the variablelength encoder 111 and the selection information to output a bit streamof coded data 18 (S19) The coded data 18 is sent to a storage system(not shown) or a transmission path.

In the flowchart of FIG. 2, the flow of steps S14 to S17 may be replacedby the flow of steps S18 and S19.

In other words, the variable length coding step S18 and multiplexingstep S19 may be executed following the quantization step S13, and thedequantizing step S14 to the storage step S17 may be executed followingthe multiplexing step S19.

The action of the acquisition/selection module 110 will be describedreferring to flowchart shown in FIG. 3.

At first the available block candidates being the encoded blocksneighboring the to-be-encoded block and having motion vectors aresearched for (S101). When the available block candidates are searchedfor, the block size for motion compensated prediction of these availableblock candidates is determined (S102). Next, it is determined whetherthe available block candidates are a unidirectional prediction or abidirectional prediction (S103). An available block is extracted fromthe available block candidates based on the determined result and theprediction mode of the to-be-encoded block. One selection block isselected for from the extracted available blocks, and informationspecifying the selection block is acquired as selection information(S104).

There will be described a process for determining a block size referringto FIGS. 4A to 4C (S102).

The adjacent blocks used in the present embodiment are assumed to beblocks, which are positioned at the left, upper left, upper and upperright of the to-be-encoded block. Therefore, when the to-be-encodedblock positions the most upper left of the frame, this to-be-encodedblock cannot be applied to the present invention because there is notthe available block adjacent to the to-be-encoded block. When theto-be-encoded block is on the upper end of the screen, the availableblock is only a left block, and when the to-be-encoded block is on theextreme left and not on the extreme upper end, the two blocks of theto-be-encoded blocks which position the upper and upper right thereof.

When the block size is a size 16×16, the block sizes for motioncompensated prediction of the adjacent blocks are four kinds of size16×16, size 16×8, size 8×16 and size 8×8 as shown in FIGS. 4A to 4C.Considering these four kinds, the adjacent blocks that may be availableblocks are 20 kinds as shown in FIGS. 4A to 4C. In other words, thereare four kinds for size 16×16 as shown in FIG. 4A, 10 kinds for size16×8 as shown in FIG. 4B, and six kinds for size 8×8 as shown in FIG.4C. In discrimination of the block size (S102), the available block issearched for according to the block size from 20 kinds of blocks. Forexample, when the size of the available block is assumed to be only size16×16, the available blocks determined by this block size are four kindsof blocks of size 16×16 as shown in FIG. 4A. In other words, theavailable blocks are a block on the upper left side of the to-be-encodedblock, a block on the upper side of the to-be-encoded block, and a blockon the left side of the to-be-encoded block and a block on the upperright side of the to-be-encoded block. In addition, even if themacroblock size was expanded not less than size 16×16, it can be theavailable block similarly to the macroblock size of 16×16. For example,when the macroblock size is 32×32, the block size for motion compensatedprediction of the adjacent block are four kinds of size 32×32, size32×16, size16×32, and size 16×16, and the adjacent blocks that may bethe available blocks are 20 kinds.

There will be described the determination of the unidirectionalprediction or bidirectional prediction which is executed by theacquisition/selection module 110 (S103) with reference to FIG. 5.

For example, the block size is limited to 16×16, and the unidirectionalor bidirectional prediction of the adjacent block with respect to theto-be-encoded block is assumed to be a case as shown in FIG. 5. Indiscrimination of the unidirectional or bidirectional prediction (S103),the available block is searched for according to the direction ofprediction. For example, the adjacent block having a predictiondirection L0 is assumed to be an available block determined in theprediction direction. In other words, the upper, left and upper rightblocks of the to-be-encoded blocks shown in FIG. 5 (a) are availableblocks determined in the prediction direction. In this case, the upperleft block of the to-be-encoded blocks is not employed. When theadjacent block including the prediction direction L1 is assumed to bethe available block determined in the prediction direction, the upperleft and upper blocks of the to-be-encoded blocks shown in FIG. 5 (b)are available blocks determined in the prediction direction. In thiscase, the left and upper right blocks of the to-be-encoded blocks arenot employed. When the adjacent block including the prediction directionL0/L1 is assumed to be the available block determined in the predictiondirection, only the upper block of the to-be-encoded blocks shown inFIG. 5 (c) is the available block determined in the predictiondirection. In this case, the left, upper left and upper right blocks ofthe to-be-encoded blocks are not employed. In addition, the predictiondirection L0 (L1) corresponds to the prediction direction of the L0prediction (L1 prediction) in AVC.

There will be described the selection information encoder 112 referringto flowchart shown in FIG. 6.

The available block of the encoded block having a motion vector issearched for from among adjacent blocks adjacent to the to-be-encodedblock, and the available block information determined by the block sizeand the unidirectional or bidirectional prediction is acquired (S201).The code tables corresponding to the number of available blocks as shownin FIG. 8 are switched using this available block information (S202).The selection information 17 sent from the acquisition/selection module110 is subjected to variable length coding using a changed code table(S203).

An example of an index of selection information is explained referringto FIG. 7 next.

When there is no available block as shown in FIG. 7 (a), the selectioninformation is not sent because the present invention is inapplicable tothis block. When there is one available block as shown in FIG. 7 (b),the selection information is not sent because a motion vector of anavailable block used for motion compensation of the to-be-encoded blockis determined in unique. When there are two available blocks as shown inFIG. 7 (c), the selection information of an index 0 or 1 is sent. Whenthere are three available blocks as shown in FIG. 7 (d), the selectioninformation of an index 0, 1 or 2 is sent. When there are four availableblocks as shown in FIG. 7 (e), the selection information of an index 0,1, 2 or 3 is sent.

In addition, as an example of setting an index of the available block,an example of setting the index to the available block in order of theleft, upper left, upper and upper right of the to-be-encoded blocks isshown in FIG. 7. In other words, the index is set to the block to beused except for the block which is not used.

There will be described a code table of the selection information 17referring to FIG. 8 next.

The selection information encoder 112 switches the code table accordingto the number of available blocks (S202). As mentioned above, when thereare two or more available blocks, the selection information 17 must beencoded.

At first when there are two available blocks, indexes 0 and 1 areneeded, and the code table is indicated by the table on the left side ofFIG. 8. When there are three available blocks, indexes 0, 1 and 2 areneeded, and the code table is indicated by the table on the center ofFIG. 8. When there are four available blocks, indexes 0, 1, 2, 3 and 4are needed, and the code table is indicated by the table on the rightside of FIG. 8. These code tables are switched according to the numberof available blocks.

There will be explained an encoding method of the selection information.

FIG. 9 shows a schematic diagram of a structure of syntax used in thisembodiment.

The syntax comprises mainly three parts, wherein High Level Syntax 801is filled with syntax information of the upper layer not less than aslice. Slice Level Syntax 804 specifies information necessary for everyslice, Macroblock Level Syntax 807 specifies a variable length codederror signal or mode information which is needed for every macroblock.

These syntaxes each comprise more detailed syntaxes. The High LevelSyntax 801 comprises syntaxes of sequence and picture levels such asSequence parameter set syntax 802 and Picture parameter set syntax 803.Slice Level Syntax 804 comprises Slice header syntax 405, Slice datasyntax 406 and so on. Further, Macroblock Level Syntax 807 comprisesmacroblock layer syntax 808, macroblock prediction syntax 809 and so on.

The syntax information necessary for this embodiment is macroblock layersyntax 808. The syntax is described hereinafter.

The “available_block_num” shown in FIGS. 10 (a) and (b) indicates thenumber of available blocks. When this is two or more, it is necessary toencode the selection information. In addition, the “mvcopy_flag”indicates a flag representing whether the motion vector of the availableblock is used in the motion compensated prediction. When there are oneor more available blocks and the flag is “1”, the motion vector of theavailable block can be used in the motion compensated prediction.Further, the “mv_select_info” indicates the selection information, andthe code table is as described above.

FIG. 10 (a) shows a syntax when selection information is encoded after“mb_type.” When, for example, the block size is only size 16×16, the“mvcopy_flag and mv_select_info” needs not be encoded if the “mb_type”is other than 16×16. If mb_type is 16×16, mvcopy_flag and mv_select_infoare encoded.

FIG. 10 (b) shows a syntax when selection information is encoded beforemb_type. If, for example, mvcopy_flag is 1, it is not necessary toencode mb_type. If mv_copy_flag is 0, mb_type is encoded.

In this embodiment, what order may be employed in a scan order forencoding. For example, a line scan or a Z scan is applicable to thepresent invention.

There will be a video decoding apparatus related to another embodimentwith reference to FIG. 11.

The coded data 18 output from the video encoding apparatus of FIG. 1 isinput to a demultiplexer 201 of the video decoding apparatus as encodeddata 21 to be decoded through a storage system or a transmission system.The demultiplexer 201 demultiplexes the encoded data 21 to separate theencoded data 21 into quantization orthogonal transformation coefficientinformation and selection information. The output terminal of thedemultiplexer 201 is connected to a variable length decoder 202. Thevariable length decoder 202 decodes the quantization orthogonaltransformation coefficient information and the selection information.The output terminal of the variable length decoder 202 is connected toan adder 206 via a dequantizer 204 and an inverse orthogonal transformer205. The dequantizer 204 dequantizes the quantized orthogonaltransformation coefficient information to transform it to an orthogonaltransformation coefficient. The inverse orthogonal transformer 205subjects the orthogonal transformation coefficient to inverse orthogonaltransform to generate a prediction error signal. The adder 206 adds theprediction error signal to the predictive coded video signal from aprediction image generator 207 to produce a video signal.

The prediction image generator 207 includes a prediction module 208 andan acquisition/selection module 209. The acquisition/selection module209 selects a selection block from available blocks using selectioninformation 23 decoded by the selection information decoder 203 of thevariable length decoder 202 and sends a motion vector 25 of theselection block to a prediction module 208. The prediction module 208motion-compensates a reference image stored in a frame memory 210 by themotion vector 25 to produce a prediction image.

The action of the video decoding apparatus of the above configurationwill be described referring to flowchart of FIG. 12.

The demultiplexer 201 demultiplexes the coded data 21 (S31), and thevariable length decoder 202 decodes it to produce quantized orthogonaltransformation coefficient information 22 (S32). In addition, theselection information decoder 203 checks the condition of the adjacentblock adjacent to a to-be-decoded block and decode it by switching codetables according to the number of the available blocks of the adjacentencoded blocks having motion vectors as shown in FIG. 8, similarly tothe selection information encoder 112 of the encoding apparatus, therebyto produce the selection information 23 (S33).

The quantized orthogonal transformation coefficient information 22 thatis information output from the variable length decoder 202 is sent tothe dequantizer 204, and the selection information 23 which isinformation output from selection information decoder 203 is sent to theacquisition/selection module 209.

The quantization orthogonal transformation coefficient information 22 isdequantized with the dequantizer 204 (S34), and then subjected toinverse orthogonal transform with the inverse orthogonal transformer 205(S35). As a result, the prediction error signal 24 is obtained. Theadder 206 adds the prediction image signal to the prediction errorsignal 24 to reproduce a video signal 26 (S36). The reproduced videosignal 27 is stored in the frame memory 210 (S37).

The prediction image generator 207 generates the prediction image 26using the motion vector of the available block that is the decoded blockneighboring the to-be-decoded block and having a motion vector, themotion vector being a motion vector of a selection block selected on thebasis of the decoded selection information 23. The acquisition/selectionmodule 209 selects the selection block from the adjacent blocks on thebasis of the available block information of the adjacent block and theselection information 23 decoded with the selection information decoder203, similarly to the acquisition/selection module 110 of the codingapparatus. The prediction module 208 generates the prediction image 26using this selected motion vector 25, and sends it to the adder 206 toproduce a video signal 27.

According to the present invention, encoding the selection informationaccording to the number of available blocks allows the selectioninformation to be sent using a suitable code table, resulting in thatadditional information of the selection information can be reduced.

In addition, using the motion vector of the available block for themotion compensated prediction of the to-be-encoded block allows theadditional information on the motion vector information to be reduced.

Furthermore, the motion vector calculation method is not fixed andimproves degrees of freedom of motion vector calculation as comparedwith a direct mode by selecting an appropriate one from among theavailable blocks.

The technique of the present invention recited in the embodiment of thepresent invention may be executed with a computer and also may bedistributed as a program capable of causing a computer to execute bystoring it in a recording medium such as a magnetic disk (flexible disk,a hard disk, etc.), an optical disk (CD-ROM, DVD, etc.), a semiconductormemory, etc.

In addition, the present invention is not limited to the aboveembodiments and may be modified in component within a scope withoutdeparting from the subject matter of the invention.

In addition, it is possible to provide various inventions by combiningappropriately a plurality of components disclosed in the aboveembodiments. For example, some components may be deleted from allcomponents shown in the embodiments. Further, the components ofdifferent embodiments may be combined appropriately.

The apparatus of the present invention is applied to an imagecompression process in a communication, a storage and a broadcast.

A part or all of the encoding apparatus and decoding apparatus relatingto the above embodiments may be implemented as a integrated circuit suchas LSI (Large Scale Integration) or as a set of Integrated Circuitchips. An integrated-circuit technology is not limited to LSI and may berealized by a dedicated circuit or a general-purpose processor.

Each of function blocks as shown in FIGS. 2, 3, 6 and 12 may beimplemented by a respective processor or a part or all of each functionblock are integrated into a processor.

Additional advantages and modifications will readily occur to thoseskilled in the art. Therefore, the invention in its broader aspects isnot limited to the specific details and representative embodiments shownand described herein. Accordingly, various modifications may be madewithout departing from the spirit or scope of the general inventiveconcept as defined by the appended claims and their equivalents.

What is claimed is:
 1. A video decoding apparatus for subjecting a videoimage to motion compensated decoding, the apparatus comprising:processing circuitry configured to: acquire a to-be-decoded block and anumber of available blocks from a decoded block adjacent to theto-be-decoded block; decode selection information specifying an index ofa block; switch a code table according to the number of the availableblocks of the adjacent blocks, wherein the available blocks aredetermined by the block size, the unidirectional or bidirectionalprediction modes of available blocks and the prediction modes of theto-be-decoded block and the available blocks are decoded neighboringblocks having motion vectors; select a block from the available blocksbased on the code table and the selection information; generate theto-be-decoded block using a motion vector of the selected block, whereinwhen there are two available blocks, a code table including two indexes0 and 1 is selected, when there are three available blocks, a code tableincluding indexes 0, 1 and 2 is selected, and when there are fouravailable blocks, a code table including indexes 0, 1, 2 and 3 isselected.
 2. A video decoding method for subjecting a video image tomotion compensated decoding, the method comprising: acquiring ato-be-decoded block and a number of available blocks from a decodedblock adjacent to the to-be-decoded block; decoding selectioninformation regarding the block, and not decoding the selectioninformation when the number of the block is 1; switching a code tableaccording to the number of the available blocks of the adjacent blocks,wherein the available blocks are determined by the block size, theunidirectional or bidirectional prediction modes of available blocks andthe prediction modes of the to-be-decoded block and the available blocksare decoded neighboring blocks having motion vectors; selecting a blockfrom the available blocks based on the code table and the selectioninformation; and generating the to-be-decoded block using a motionvector of the selected block, wherein when there are two availableblocks, a code table including two indexes 0 and 1 is selected, whenthere are three available blocks, a code table including indexes 0, 1and 2 is selected, and when there are four available blocks, a codetable including indexes 0, 1, 2, and 3 is selected.
 3. A non-transitorycomputer-readable medium storing instructions that, when executed, causea computer to subject a video image to motion compensated decoding, theinstructions causing the computer to execute a step of acquiring ato-be-decoded block and a number of available blocks from a decodedblock adjacent to the to-be-decoded block; a step of decoding selectioninformation regarding the block, and a step of not decoding theselection information when the number of the block is 1; a step ofswitching a code table according to the number of the available blocksof the adjacent blocks, wherein the available blocks are determined bythe block size, the unidirectional or bidirectional prediction modes ofavailable blocks and the prediction modes of the to-be-decoded block andthe available blocks are decoded neighboring blocks having motionvectors; a step of selecting a block from the available blocks based onthe code table and the selection information; and a step of generatingthe to-be-decoded block using a motion vector of the selected block,wherein when there are two available blocks, a code table including twoindexes 0 and 1 is selected, when there are three available blocks, acode table including indexes 0, 1 and 2 is selected, and when there arefour available blocks, a code table including indexes 0, 1, 2, and 3 isselected.
 4. A video decoding apparatus for subjecting a video image tomotion compensated decoding, the apparatus decoding an encoded data byperforming: acquiring a to-be-decoded block and a number of availableblocks from a decoded block adjacent to the to-be-decoded block;decoding selection information regarding the block, and not decoding theselection information when the number of the block is 1; switching acode table according to the number of the available blocks of theadjacent blocks, wherein the available blocks are determined by theblock size, the unidirectional or bidirectional prediction modes ofavailable blocks and the prediction modes of the to-be-decoded block andthe available blocks are decoded neighboring blocks having motionvectors; selecting a block from the available blocks based on the codetable and the selection information; and generating the to-be-decodedblock using a motion vector of the selected block, wherein when thereare two available blocks, a code table including two indexes 0 and 1 isselected, when there are three available blocks, a code table includingindexes 0, 1 and 2 is selected, and when there are available fourblocks, a code table including indexes 0, 1, 2, and 3 is selected.
 5. Avideo decoding method for subjecting a video image to motion compensateddecoding, the method decoding an encoded data by performing: acquiring ato-be-decoded block and a number of available blocks from a decodedblock adjacent to the to-be-decoded block; decoding selectioninformation regarding the block, and not decoding the selectioninformation when the number of the block is 1; switching a code tableaccording to the number of the available blocks of the adjacent blocks,wherein the available blocks are determined by the block size, theunidirectional or bidirectional prediction modes of available blocks andthe prediction modes of the to-be-decoded block and the available blocksare decoded neighboring blocks having motion vectors; selecting a blockfrom the available blocks based on the code table and the selectioninformation; and generating the to-be-decoded block using a motionvector of the selected block, wherein when there are two availableblocks, a code table including two indexes 0 and 1 is selected, whenthere are three available blocks, a code table including indexes 0, 1and 2 is selected, and when there are four available blocks, a codetable including indexes 0, 1, 2, and 3 is selected.